#include <cstdio>
#include <queue>
#include <vector>
#include <utility>
#include <cstring>
using namespace std;
typedef pair<int, int> pii;

#define MAXN 505

vector<pii> G[MAXN];
int N, M, W;
int dis[MAXN];
bool vis[MAXN];
int cnt[MAXN];

bool SPFD(int s) {
	queue<int> q;
	memset(dis, 0x3F, sizeof(dis));
	memset(cnt, 0, sizeof(cnt));
	dis[1] = 0;
	vis[s] = true;
	cnt[s]++;
	q.push(s);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		for (vector<pii>::iterator it = G[u].begin(); it != G[u].end(); it++) {
			int v = it->first;
			int t = it->second;
			if (dis[v] > dis[u]+t) {
				dis[v] = dis[u]+t;
//				if (dis[v] < 0) {
//					//printf("BINGO!\n");
//					return true;
//				}
				if (!vis[v]) {
					//printf("%d-%d  %d\n", u, v, dis[u]+t);
					vis[v] = true;
					cnt[v]++;
					if (cnt[v] >= N) return true;
					q.push(v);
				}
			}
		}
		vis[u] = false;
	}
	return false;
}

int main() {
	int kase;
	scanf("%d", &kase);
	while (kase--) {
		scanf("%d%d%d", &N, &M, &W);
		for (int i=1; i<=N; i++) {
			G[i] = vector<pii>();
		}
		for (int i=1; i<=M; i++) {
			int S, E, T;
			scanf("%d%d%d", &S, &E, &T);
			G[S].push_back(make_pair(E, T));
			G[E].push_back(make_pair(S, T));
		}
		for (int i=1; i<=W; i++) {
			int S, E, T;
			scanf("%d%d%d", &S, &E, &T);
			G[S].push_back(make_pair(E, -T));
		}
		memset(vis, 0, sizeof(vis));
		bool r = SPFD(1);
		if (r) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
